package com.example.demo.controller;

import com.example.demo.utils.Constant;
import com.example.demo.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <h3>wechat-token</h3>
 * <p></p>
 *
 * @author : zhengyue
 * @date : 2021-02-20 10:39
 **/
@RestController
@RequestMapping("wechat")
public class WechatController {
    @Autowired
    private RedisUtils redisUtils;

    @GetMapping("accessToken")
    public String accessToken() {
        String token = redisUtils.get(Constant.ACCESS_TOKEN);
        if(StringUtils.isEmpty(token)) {
            return "access_token已过期，检查appid或者secret是否正确";
        }
        return token;
    }
}
